package com.ef.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.ef.constant.EClassType;
import com.ef.constant.StatusType;

@Entity
public class ClassType implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@Column(length = 100)
	private String name;

	@Column(length = 500)
	private String description;

	
	@Enumerated(value = EnumType.STRING)
	private StatusType status = StatusType.VALID;

 
	/**
	 * 课程的标准类型<br/>
	 * 在设置的时候要求选定标准节点.
	 * 用于业务规则的判断.
	 */
	@Enumerated(value = EnumType.STRING)
	private EClassType type ;
	 
	@ManyToOne(fetch = FetchType.LAZY)
	private User updateUser;

	@Temporal(TemporalType.TIMESTAMP)
	private Date updateTime;
	
	public EClassType getType() {
		return type;
	}

	public void setType(EClassType type) {
		this.type = type;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public StatusType getStatus() {
		return status;
	}

	public void setStatus(StatusType status) {
		this.status = status;
	}
	
	public String toString(){
		return name;
	}
	@Override
	public boolean equals(Object obj) {
		if (obj!=null&&obj instanceof ClassType){
			ClassType t=(ClassType)obj;
			if (this.id==null&&t.id==null){
				return true;
			}
			if (this.id==null||t.id==null){
				return false;
			}
			return this.getId().equals(t.getId());
		}
		return false;
	}

	public User getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(User updateUser) {
		this.updateUser = updateUser;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
}
